package org.tgcloud.group.web.controller.manager.notify;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.*;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.custom.Permissions;
import org.tgcloud.group.service.manager.notify.NotifyTemplateService;
import org.tgcloud.group.web.controller.manager.ManageAPPBaseController;
import org.tgcloud.group.web.controller.req.notify.notifyTemplateReq.NotifyTemplatePageReqVO;
import org.tgcloud.group.web.controller.req.notify.notifyTemplateReq.NotifyTemplateSaveReqVO;

/**
 * @Author: zhy
 * @Created: 2025-09-19-上午11:43
 * @Description:
 */
@Api(tags = "消息模块管理相关接口")
@RestController
@RequestMapping("/manager/pc/user/notifyTemplate")
@EnableAutoConfiguration
public class NotifyTemplateManageController extends ManageAPPBaseController {

    @Autowired
    private NotifyTemplateService notifyTemplateService;

    @PostMapping("/create")
    @ApiOperation(value = "创建站内信模版")
    @ResponseBody
    @Permissions("notifyTemplate:create")
    public APPResultMessage createNotifyTemplate(@RequestBody NotifyTemplateSaveReqVO createReq) {
        return notifyTemplateService.createNotifyTemplate(createReq);
    }

    @PostMapping("/update")
    @ApiOperation(value = "更新站内信模版")
    @ResponseBody
    @Permissions("notifyTemplate:update")
    public APPResultMessage updateNotifyTemplate(@RequestBody NotifyTemplateSaveReqVO updateReq) {
        return notifyTemplateService.updateNotifyTemplate(updateReq);
    }

    @PostMapping("/delete")
    @ApiOperation(value = "删除站内信模版")
    @ResponseBody
    @Permissions("notifyTemplate:delete")
    public APPResultMessage deleteNotifyTemplate(@RequestParam("id") Long id) {
        return notifyTemplateService.deleteNotifyTemplate(id);
    }

    @PostMapping("/get")
    @ApiOperation(value = "获得站内信模版")
    @ResponseBody
    @Permissions("notifyTemplate:view")
    public APPResultMessage getNotifyTemplate(@RequestParam("id") Long id) {
        return notifyTemplateService.getNotifyTemplate(id);
    }


    @PostMapping("/page")
    @ApiOperation(value = "获得站内信模版分页")
    @ResponseBody
    @Permissions("notifyTemplate:view")
    public APPResultMessage getNotifyTemplatePage(@RequestBody NotifyTemplatePageReqVO pageVO) {
        return notifyTemplateService.getNotifyTemplatePage(pageVO);
    }


    @PostMapping("/sendTest")
    @ApiOperation(value = "发送测试")
    @ResponseBody
    public APPResultMessage doSendNotifyTest(@RequestParam("id") Long id) {
        return notifyTemplateService.doSendNotifyTest(id);
    }
    
}
